//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "CPICapFloorTermPriceSurface.h"
using namespace Cephei::QL::Experimental::Inflation;
#include <gen/QL/Times/Period.h>
#include <gen/QL/Math/Matrix.h>
#include <gen/QL/Times/Calendar.h>
#include <gen/QL/Times/DayCounter.h>
#include <gen/QL/Indexes/ZeroInflationIndex.h>
#include <gen/QL/Termstructures/YieldTermStructure.h>
#include <gen/QL/Termstructures/Inflation/Seasonality.h>
#include <gen/QL/Termstructures/InflationTermStructure.h>
using namespace Cephei::QL::Times;
using namespace Cephei::QL::Math;
using namespace Cephei::QL::Indexes;
using namespace Cephei::QL::Termstructures;
using namespace Cephei::QL::Termstructures::Inflation;
#define HANDLE
#define ABSTRACT
#undef STRUCT
Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CCPICapFloorTermPriceSurface (boost::shared_ptr<QuantLib::CPICapFloorTermPriceSurface>& childNative, Object^ owner) : CInflationTermStructure(CCPICapFloorTermPriceSurface::typeid)
{
#ifdef HANDLE
	_phCPICapFloorTermPriceSurface = NULL;
#endif
	_ppCPICapFloorTermPriceSurface = &childNative;
    _ppInflationTermStructure = new boost::shared_ptr<QuantLib::InflationTermStructure> (boost::dynamic_pointer_cast<QuantLib::InflationTermStructure> (*_ppCPICapFloorTermPriceSurface));
}
Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CCPICapFloorTermPriceSurface (QuantLib::CPICapFloorTermPriceSurface& childNative, Object^ owner) : CInflationTermStructure(CCPICapFloorTermPriceSurface::typeid)
{
#ifdef HANDLE
	_phCPICapFloorTermPriceSurface = NULL;
#endif
	_ppCPICapFloorTermPriceSurface = new boost::shared_ptr<QuantLib::CPICapFloorTermPriceSurface> (&childNative);
    _ppInflationTermStructure = new boost::shared_ptr<QuantLib::InflationTermStructure> (boost::dynamic_pointer_cast<QuantLib::InflationTermStructure> (*_ppCPICapFloorTermPriceSurface));
    _CPICapFloorTermPriceSurfaceOwner = owner;
    _InflationTermStructureOwner = owner;
}

Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CCPICapFloorTermPriceSurface (CCPICapFloorTermPriceSurface^ copy) : CInflationTermStructure(CCPICapFloorTermPriceSurface::typeid)
{
#ifdef HANDLE
	_phCPICapFloorTermPriceSurface = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppCPICapFloorTermPriceSurface = new boost::shared_ptr<QuantLib::CPICapFloorTermPriceSurface> (copy->GetShared());
        _ppInflationTermStructure = new boost::shared_ptr<QuantLib::InflationTermStructure> (boost::dynamic_pointer_cast<QuantLib::InflationTermStructure> (*_ppCPICapFloorTermPriceSurface));
    }
}
Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CCPICapFloorTermPriceSurface (PLATFORM::Type^ t) : CInflationTermStructure(CCPICapFloorTermPriceSurface::typeid)
{
#ifdef HANDLE
	_phCPICapFloorTermPriceSurface = NULL;
#endif
	if (!t->IsSubclassOf(CCPICapFloorTermPriceSurface::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CCPICapFloorTermPriceSurface (QuantLib::Handle<QuantLib::CPICapFloorTermPriceSurface>& childNative, Object^ owner)  : CInflationTermStructure(CCPICapFloorTermPriceSurface::typeid)
{
	_phCPICapFloorTermPriceSurface = &childNative;
	_ppCPICapFloorTermPriceSurface = &static_cast<boost::shared_ptr<QuantLib::CPICapFloorTermPriceSurface>>(childNative.currentLink());
    _ppInflationTermStructure = new boost::shared_ptr<QuantLib::InflationTermStructure> (boost::dynamic_pointer_cast<QuantLib::InflationTermStructure> (*_ppCPICapFloorTermPriceSurface));
    _CPICapFloorTermPriceSurfaceOwner = owner;
}
Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CCPICapFloorTermPriceSurface (QuantLib::Handle<QuantLib::CPICapFloorTermPriceSurface> childNative)  : CInflationTermStructure(CCPICapFloorTermPriceSurface::typeid)
{
	_phCPICapFloorTermPriceSurface = &childNative;
	_ppCPICapFloorTermPriceSurface = &static_cast<boost::shared_ptr<QuantLib::CPICapFloorTermPriceSurface>>(childNative.currentLink());
    _ppInflationTermStructure = new boost::shared_ptr<QuantLib::InflationTermStructure> (boost::dynamic_pointer_cast<QuantLib::InflationTermStructure> (*_ppCPICapFloorTermPriceSurface));
}
#endif
#ifdef STRUCT
Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CCPICapFloorTermPriceSurface (QuantLib::CPICapFloorTermPriceSurface childNative)  : CInflationTermStructure(CCPICapFloorTermPriceSurface::typeid)
{
#ifdef HANDLE
	_phCPICapFloorTermPriceSurface = NULL;
#endif
	_ppCPICapFloorTermPriceSurface = new boost::shared_ptr<QuantLib::CPICapFloorTermPriceSurface> (new QuantLib::CPICapFloorTermPriceSurface (childNative));
    _ppInflationTermStructure = new boost::shared_ptr<QuantLib::InflationTermStructure> (boost::dynamic_pointer_cast<QuantLib::InflationTermStructure> (*_ppCPICapFloorTermPriceSurface));
}
#endif

Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::~CCPICapFloorTermPriceSurface ()
{
    if (_ppCPICapFloorTermPriceSurface != NULL)
    {
	    delete _ppCPICapFloorTermPriceSurface;
        _ppCPICapFloorTermPriceSurface = NULL;
    }
}
Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::!CCPICapFloorTermPriceSurface ()
{
    if (_ppCPICapFloorTermPriceSurface != NULL)
    {
	    delete _ppCPICapFloorTermPriceSurface;
    }
}
QuantLib::CPICapFloorTermPriceSurface& Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::GetReference ()
{
    if (_ppCPICapFloorTermPriceSurface == NULL) throw REFNEW NativeNullException ();
	return **_ppCPICapFloorTermPriceSurface;
}
boost::shared_ptr<QuantLib::CPICapFloorTermPriceSurface>& Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::GetShared ()
{
    if (_ppCPICapFloorTermPriceSurface == NULL) throw REFNEW NativeNullException ();
	return *_ppCPICapFloorTermPriceSurface;
}
QuantLib::CPICapFloorTermPriceSurface* Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::GetPointer ()
{
    if (_ppCPICapFloorTermPriceSurface == NULL) throw REFNEW NativeNullException ();
	return &**_ppCPICapFloorTermPriceSurface;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::CPICapFloorTermPriceSurface>& Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::GetHandle ()
{
	if (_phCPICapFloorTermPriceSurface == NULL)
	{
		_phCPICapFloorTermPriceSurface = new Handle<QuantLib::CPICapFloorTermPriceSurface> (*_ppCPICapFloorTermPriceSurface);
	}
	return *_phCPICapFloorTermPriceSurface;
}
#endif
bool Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::HasNative () 
{
	return (_ppCPICapFloorTermPriceSurface != NULL);
}

DateTime Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::BaseDate::get ()
{
    try
    {
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppCPICapFloorTermPriceSurface)->baseDate ( );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
QL::Times::BusinessDayConventionEnum Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::BusinessDayConvention::get ()
{
    try
    {
    	QuantLib::BusinessDayConvention _rv = (QuantLib::BusinessDayConvention)(*_ppCPICapFloorTermPriceSurface)->businessDayConvention ( );   
        QL::Times::BusinessDayConventionEnum _nrv = (QL::Times::BusinessDayConventionEnum)_rv;
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CapPrice (DateTime d, Double k)
{
    try
    {
        QuantLib::Date _d = (QuantLib::Date)ValueHelper::Convert (d); //a
        QuantLib::Rate _k = (QuantLib::Rate)ValueHelper::Convert (k); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppCPICapFloorTermPriceSurface)->capPrice ( _d,  _k );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CapPrice (Cephei::QL::Times::IPeriod^ d, Double k)
{
    CPeriod^ _Cd;
    try
    {
        _Cd = safe_cast<CPeriod^> (d);
        _Cd->Lock();
        QuantLib::Period& _d = static_cast<QuantLib::Period&> (_Cd->GetReference ()); 
        QuantLib::Rate _k = (QuantLib::Rate)ValueHelper::Convert (k); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppCPICapFloorTermPriceSurface)->capPrice ( _d,  _k );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cd != nullptr) _Cd->Unlock();
    }
}
Cephei::QL::Math::IMatrix^ Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CapPrices::get ()
{
    try
    {
    	QuantLib::Matrix & _rv = (QuantLib::Matrix &)(*_ppCPICapFloorTermPriceSurface)->capPrices ( );   
        Cephei::QL::Math::CMatrix^ _nrv = REFNEW Cephei::QL::Math::CMatrix (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Double>^ Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CapStrikes::get ()
{
    try
    {
    	std::vector<QuantLib::Rate> _rv = (std::vector<QuantLib::Rate>)(*_ppCPICapFloorTermPriceSurface)->capStrikes ( );   
        Cephei::Core::IVector<Double>^ _nrv = REFNEW CoVector<Double> (REFNEW CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
DateTime Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::CpiOptionDateFromTenor (Cephei::QL::Times::IPeriod^ p)
{
    CPeriod^ _Cp;
    try
    {
        _Cp = safe_cast<CPeriod^> (p);
        _Cp->Lock();
        QuantLib::Period& _p = static_cast<QuantLib::Period&> (_Cp->GetReference ()); 
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppCPICapFloorTermPriceSurface)->cpiOptionDateFromTenor ( _p );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cp != nullptr) _Cp->Unlock();
    }
}
Double Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::FloorPrice (DateTime d, Double k)
{
    try
    {
        QuantLib::Date _d = (QuantLib::Date)ValueHelper::Convert (d); //a
        QuantLib::Rate _k = (QuantLib::Rate)ValueHelper::Convert (k); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppCPICapFloorTermPriceSurface)->floorPrice ( _d,  _k );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::FloorPrice (Cephei::QL::Times::IPeriod^ d, Double k)
{
    CPeriod^ _Cd;
    try
    {
        _Cd = safe_cast<CPeriod^> (d);
        _Cd->Lock();
        QuantLib::Period& _d = static_cast<QuantLib::Period&> (_Cd->GetReference ()); 
        QuantLib::Rate _k = (QuantLib::Rate)ValueHelper::Convert (k); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppCPICapFloorTermPriceSurface)->floorPrice ( _d,  _k );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cd != nullptr) _Cd->Unlock();
    }
}
Cephei::QL::Math::IMatrix^ Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::FloorPrices::get ()
{
    try
    {
    	QuantLib::Matrix & _rv = (QuantLib::Matrix &)(*_ppCPICapFloorTermPriceSurface)->floorPrices ( );   
        Cephei::QL::Math::CMatrix^ _nrv = REFNEW Cephei::QL::Math::CMatrix (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Double>^ Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::FloorStrikes::get ()
{
    try
    {
    	std::vector<QuantLib::Rate> _rv = (std::vector<QuantLib::Rate>)(*_ppCPICapFloorTermPriceSurface)->floorStrikes ( );   
        Cephei::Core::IVector<Double>^ _nrv = REFNEW CoVector<Double> (REFNEW CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::Core::IVector<Cephei::QL::Times::IPeriod^>^ Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::Maturities::get ()
{
    try
    {
    	std::vector<QuantLib::Period> _rv = (std::vector<QuantLib::Period>)(*_ppCPICapFloorTermPriceSurface)->maturities ( );   
        CoVector<Cephei::QL::Times::IPeriod^>^ _nrv = REFNEW CoVector<Cephei::QL::Times::IPeriod^>(REFNEW CPeriodVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
DateTime Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::MaxDate::get ()
{
    try
    {
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppCPICapFloorTermPriceSurface)->maxDate ( );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::MaxStrike::get ()
{
    try
    {
    	QuantLib::Rate _rv = (QuantLib::Rate)(*_ppCPICapFloorTermPriceSurface)->maxStrike ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
DateTime Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::MinDate::get ()
{
    try
    {
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppCPICapFloorTermPriceSurface)->minDate ( );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::MinStrike::get ()
{
    try
    {
    	QuantLib::Rate _rv = (QuantLib::Rate)(*_ppCPICapFloorTermPriceSurface)->minStrike ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::Nominal::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppCPICapFloorTermPriceSurface)->nominal ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Times::IPeriod^ Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::ObservationLag::get ()
{
    try
    {
    	QuantLib::Period _rv = (QuantLib::Period)(*_ppCPICapFloorTermPriceSurface)->observationLag ( );   
        Cephei::QL::Times::CPeriod^ _nrv = REFNEW Cephei::QL::Times::CPeriod (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::Price (DateTime d, Double k)
{
    try
    {
        QuantLib::Date _d = (QuantLib::Date)ValueHelper::Convert (d); //a
        QuantLib::Rate _k = (QuantLib::Rate)ValueHelper::Convert (k); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppCPICapFloorTermPriceSurface)->price ( _d,  _k );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::Price (Cephei::QL::Times::IPeriod^ d, Double k)
{
    CPeriod^ _Cd;
    try
    {
        _Cd = safe_cast<CPeriod^> (d);
        _Cd->Lock();
        QuantLib::Period& _d = static_cast<QuantLib::Period&> (_Cd->GetReference ()); 
        QuantLib::Rate _k = (QuantLib::Rate)ValueHelper::Convert (k); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppCPICapFloorTermPriceSurface)->price ( _d,  _k );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_Cd != nullptr) _Cd->Unlock();
    }
}
Cephei::Core::IVector<Double>^ Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::Strikes::get ()
{
    try
    {
    	std::vector<QuantLib::Rate> _rv = (std::vector<QuantLib::Rate>)(*_ppCPICapFloorTermPriceSurface)->strikes ( );   
        Cephei::Core::IVector<Double>^ _nrv = REFNEW CoVector<Double> (REFNEW CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Indexes::IZeroInflationIndex^ Cephei::QL::Experimental::Inflation::CCPICapFloorTermPriceSurface::ZeroInflationIndex::get ()
{
    try
    {
    	Handle<QuantLib::ZeroInflationIndex> _rv = (Handle<QuantLib::ZeroInflationIndex>)(*_ppCPICapFloorTermPriceSurface)->zeroInflationIndex ( );   
        Cephei::QL::Indexes::CZeroInflationIndex^ _nrv = REFNEW Cephei::QL::Indexes::CZeroInflationIndex (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

